<?php

use yii\helpers\Html;

$this->title = $cruise->name;
?>

<?= yii\web\View::registerCssFile("/css/magic-check.css",['depends' => 'app\assets\AppAsset']) ?>
<style type="text/css">
	.order-view font {color:#9E9A9A;margin-right:10px;}
	.order{border: 1px solid #ddd;text-align: center;height: 100px;background: #dff0d8;line-height: 100px;border-radius: 4px;}
</style>

<div class="order-view">

    <h2 class="page-header">
    	 <small><?=yii::$app->params['template'][$template_id]?></small>
    	 &nbsp;&nbsp;<small>[ <?= Html::encode($this->title) ?> ]</small>
    </h2>

    <input type="hidden" name="template_id" id="template_id" value="<?=$template_id?>">
	<input type="hidden" name="cruise_id" id="cruise_id" value="<?=$cruise->id?>">
	<input type="hidden" value="<?php echo Yii::$app->getRequest()->getCsrfToken(); ?>" name="_csrf" id="_csrf" />

	<div class="row">
    	 
    	 <div class="col-md-6">
    	 	<div class="row">
    	 		<div class="col-md-6">
	    	 		<div class="order">
	    	 			 总计<span id="order_num"><?=$room_num?></span>个房间
	    	 		</div>
    	 		</div>
    	 		<div class="col-md-6">
	    	 		<div class="order">
	    	 			 总计<span id="people_num"><?=$people_num?></span>人
	    	 		</div>
    	 		</div>
    	 	</div>
    	 </div>	
	</div>

	<div class="row"  style="text-align: center;margin-top: 30px;">
		
		<button type="button" class="btn btn-warning" id="create_name">生成团队名单</button>
	
	</div>
	
</div>


<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">


$("#create_name").click(function(){

	var template_id = $("#template_id").val();
	var cruise_id = $("#cruise_id").val();
	var _csrf = $("#_csrf").val();


	$.ajax({
		   type: "POST",
		   async:false, 
		   url: "/cruise/customer/excel",
		   data: {"_csrf":_csrf,"template_id":template_id,"cruise_id":cruise_id},
		   success: function(msg){
		       var res = $.parseJSON(msg);
		       if(res.status == 0){
		       	   alert("生成团队名单失败");
		       	   return false;
		       }else if(res.status == 1){
		       		var href = "/cruise/customer/download-file?name="+res.data.down_name+"&url="+res.data.down_url;
		       		window.location.href = href;
		       }

		   }
		});

});

</script>
<?php app\components\JsBlock::end() ?>
